package com.ruben.simpleboot.config

import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor
import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor
import com.ruben.simpleboot.interceptor.RecycleBinInnerInterceptor
import com.ruben.simpleboot.interceptor.RecycleBinLineHandler
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration

@Configuration
class MybatisPlusConfig {

    @Bean
    fun mybatisPlusInterceptor(): MybatisPlusInterceptor {
        return MybatisPlusInterceptor()
            .apply { addInnerInterceptor(RecycleBinInnerInterceptor(RecycleBinLineHandler())) }
            .apply { addInnerInterceptor(OptimisticLockerInnerInterceptor()) }
            .apply { addInnerInterceptor(PaginationInnerInterceptor()) }
    }
}